using System;
using muduoDotNet.Examples.ReflectionProtocol;

namespace muduoDotNet.Examples
{
    /// <summary>
    /// 示例程序启动器
    /// </summary>
    class ExampleRunner
    {
        static void Main(string[] args)
        {
            Logger.Info("=== muduoDotNet Examples Runner ===");
            Logger.Info("Available examples:");
            Logger.Info("1. Echo Server (original)");
            Logger.Info("2. Echo Client (original)");
            Logger.Info("3. Protobuf Echo Server");
            Logger.Info("4. Protobuf Echo Client");
            Logger.Info("5. Performance Test");
            Logger.Info("6. Reflection Protocol Server");
            Logger.Info("7. Reflection Protocol Client");
            Logger.Info("8. Enhanced Server (with connection pool, recovery, monitoring)");
            Logger.Info("9. Enhanced Client (with connection pool, recovery, monitoring)");
            Logger.Info("Enter choice (1-9) or 'q' to quit:");

            while (true)
            {
                var input = Console.ReadLine();
                
                switch (input?.Trim())
                {
                    case "1":
                        Logger.Info("Running Echo Server Example...");
                        EchoServerExample.RunExample();
                        break;
                        
                    case "2":
                        Logger.Info("Running Echo Client Example...");
                        EchoClientExample.RunExample();
                        break;
                        
                    case "3":
                        Logger.Info("Running Protobuf Echo Server Example...");
                        ProtobufEchoServerExample.RunExample();
                        break;
                        
                    case "4":
                        Logger.Info("Running Protobuf Echo Client Example...");
                        ProtobufEchoClientExample.RunExample();
                        break;
                        
                    case "5":
                        Logger.Info("Running Performance Test...");
                        RunPerformanceTest();
                        break;
                    
                    case "6":
                        Logger.Info("Running Reflection Protocol Server Example...");
                        ReflectionProtocol.ReflectionProtocolServerExample.RunExample();
                        break;
                    
                    case "7":
                        Logger.Info("Running Reflection Protocol Client Example...");
                        ReflectionProtocol.ReflectionProtocolClientExample.RunExample();
                        break;
                        
                    case "8":
                        Logger.Info("Running Enhanced Server Example...");
                        EnhancedServerExample.RunExample();
                        break;
                        
                    case "9":
                        Logger.Info("Running Enhanced Client Example...");
                        EnhancedClientExample.RunExample();
                        break;
                        
                    case "q":
                    case "Q":
                        Logger.Info("Goodbye!");
                        return;
                        
                    default:
                        Logger.Warning("Invalid choice. Please enter 1-9 or 'q'.");
                        break;
                }

                Logger.Info("\nPress Enter to return to menu...");
                Console.ReadLine();
                Console.Clear();
                Logger.Info("=== muduoDotNet Examples Runner ===");
                Logger.Info("Available examples:");
                Logger.Info("1. Echo Server (original)");
                Logger.Info("2. Echo Client (original)");
                Logger.Info("3. Protobuf Echo Server");
                Logger.Info("4. Protobuf Echo Client");
                Logger.Info("5. Performance Test");
                Logger.Info("6. Reflection Protocol Server");
                Logger.Info("7. Reflection Protocol Client");
                Logger.Info("8. Enhanced Server (with connection pool, recovery, monitoring)");
                Logger.Info("9. Enhanced Client (with connection pool, recovery, monitoring)");
                Logger.Info("Enter choice (1-9) or 'q' to quit:");
            }
        }

        /// <summary>
        /// 运行性能测试
        /// </summary>
        static void RunPerformanceTest()
        {
            Logger.Info("Performance test not implemented yet");
            // TODO: 实现性能测试
        }
    }
}